package com.bdc.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bdc.bean.Product;
import com.bdc.service.ServiceFactory;

public class ProductListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String productType = req.getParameter("productType");
		String pageId = req.getParameter("pageId");
		
		List<Product> products = ServiceFactory.getProductService().getProductList(productType);
		req.setAttribute("pageId", pageId);
		req.setAttribute("productType", productType);
		req.setAttribute("products", products);
		RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/product/product.jsp");
		dispatcher.forward(req, resp);
	}
}
